package interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import controller.InterceptorAction;
import lombok.Data;

import java.util.Date;

@Data
public class TestInterceptor extends AbstractInterceptor {
    private int sleep;
    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        System.out.println("TestInterceptor"+new Date().toLocaleString());
        InterceptorAction action= (InterceptorAction) invocation.getAction();//获取与Action的连接
        System.out.println(action);
        String result=invocation.invoke();//放行
        System.out.println("Test执行完毕"+new Date().toLocaleString());
        System.out.println(action.getSleep());
        return result;
    }
}
